Kerry Back
BUSI 721, Fall 2022
JGSB, Rice University
There are various reasons to impose ex-ante constraints on portfolio weights.
minimize \(\frac{\text{A}}{2}w^⊤\text{C}w-x_sr_s+x_br_b-\bar{r}^⊤w\)
and \(-w < 0\)
-choice vector: \((x_s,x_b,w)^⊤\)
-\(\text{n} \times \text{n}\) quadratic term with zeros and \(\text{AC}\) in bottom right
-linear term: \((-1,1,-\bar{r})^⊤\)
-\(\text{n} \times \text{n}\) inequality matrix = -I
-\(1 \times \text{n}\) equality matrix: (1,-1,1_n)
-right-hand side of inequality =0’s, right-hand side of equality=1
rs = 0.04
rb = 0.08
# quadratic and linear terms
Q = np.zeros((5, 5))
Q[2:, 2:] = raver*C
p = np.concatenate(([-rs, rb], -means))
# inequalities
G = - np.identity(5)
h = np.zeros(2)
# equalities
A = np.concatenate(([1, -1], np.ones(3)))
b = np.ones(1)from last session, only changing \(\text{G}\)
from cvxopt import matrix
from cvxopt.solvers import qp
Q = matrix(Q, (5, 5))
p = matrix(p, (5, 1))
G = matrix(G, (2, 5))
h = matrix(h, (2, 1))
A = matrix(A, (1, 5))
b = matrix(b, (1, 1))
sol = qp(Q, p, G, h, A, b)
xs, xb, w1, w2, w3 = np.array(sol["x"])Same as last session. Solution is the same too for these parameters.
Prohibiting short sales doesn’t matter to someone who doesn’t want to short anyway.
import numpy as np
# standard deviations
sds = np.array([0.15, 0.25, 0.35])
S = np.diag(sds)
# correlations
r12 = 0.15
r13 = 0.6
r23 = 0.3
R = np.identity(3)
R[0, 1] = R[1, 0] = r12
R[0, 2] = R[2, 0] = r13
R[1, 2] = R[2, 1] = r23
# covariance matrix
C = S @ R @ S
# optimal portfolio
r = 0.04
means = np.array([0.06, 0.1, 0.09])
raver = 4
w = np.linalg.solve(C, (means-r)/raver)Solution is \(\text{w}_1=0.14\) \(\text{w}_2=0.22\) \(\text{w}_3=0.02\)
save 0.62
\(r_{b}=\) borrowing rate > saving rate \(= r_{s}\)
\(x_{b} \geq 0 =\) amount borrowed
\(x_{s} \geq 0 =\) amount saved
Portfolio expected return: \[\small x_{s}r_{s}-x_{b}r_{b}+\bar{r}^⊤w\]
Assets=Investments:
\[\tiny x_{s}+\sum_{i=1}^n w_{i} = 1 + x_{b} \iff x_{s}+1_{n}^⊤w=1+x_{b}\]
minimize \(\frac{\text{A}}{2}w^⊤\text{C}w-x_{s}r_{s}+x_{b}r_{b}-\bar{r}^⊤w\)
subject to \(-x_{s} \leq 0, -x_{b} \leq 0, x_{s}-x{b}+1_n^⊤w=1\)
from cvxopt import matrix
from cvxopt.solvers import qp
Q = matrix(Q, (5, 5))
p = matrix(p, (5, 1))
G = matrix(G, (2, 5))
h = matrix(h, (2, 1))
A = matrix(A, (1, 5))
b = matrix(b, (1, 1))
sol = qp(Q, p, G, h, A, b)
xs, xb, w1, w2, w3 = np.array(sol["x"])Solution is same as in last module for these parameters. Higher borrowing rate doesn’t matter for someone who doesn’t want to borrow at a lower rate.